package com.wicket.okroperation.web.contorller;

import cn.hutool.core.bean.BeanUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.page.PageMethod;
import com.wicket.okroperation.biz.service.BlockchainService;
import com.wicket.okroperation.biz.service.dto.req.*;
import com.wicket.okroperation.biz.service.dto.res.*;
import com.wicket.okroperation.common.ro.OkrResult;
import com.wicket.okroperation.common.util.CommonFunctionHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：
 * @date ：
 *
 *
 * @version 1.0
 */
@RestController
@RequestMapping("/operation/blockchain/")
public class BlockchainController {

  @Autowired
  BlockchainService blockchainService;
/**
   * D6新增区块链哈希值(公共)
   */
    @PostMapping("addHashValueCom")
    public OkrResult<AddHashValueComRespDto> addHashValueCom(@RequestBody @Validated AddHashValueComReqDto reqDTO){
    return OkrResult.success(blockchainService.addHashValueCom(reqDTO));
    }
/**
   * D6新增存证数据证书(公共)
   */
    @PostMapping("addDataDepositCertificationCom")
    public OkrResult<AddDataDepositCertificationComRespDto> addDataDepositCertificationCom(@RequestBody @Validated AddDataDepositCertificationComReqDto reqDTO){
    return OkrResult.success(blockchainService.addDataDepositCertificationCom(reqDTO));
    }
/**
   * D6新增区块链证书
   */
    @PostMapping("addBlockchainCertification")
    public OkrResult<AddBlockchainCertificationRespDto> addBlockchainCertification(@RequestBody @Validated AddBlockchainCertificationReqDto reqDTO){
    return OkrResult.success(blockchainService.addBlockchainCertification(reqDTO));
    }
/**
   * D6查询区块链证书列表
   */
    @PostMapping("queryBlockchainCertificationList")
    public OkrResult<QueryBlockchainCertificationListRespDto> queryBlockchainCertificationList(@RequestBody @Validated QueryBlockchainCertificationListReqDto reqDTO){
    Page<?> page = CommonFunctionHelper.startPage(reqDTO.getPageNum(),reqDTO.getPageSize());

        QueryBlockchainCertificationListRespDto retData = blockchainService.queryBlockchainCertificationList(reqDTO);

        retData.setPageNum(page.getPageNum());
        retData.setPageSize(page.getPageSize());
        retData.setTotalNum(page.getTotal());
        return OkrResult.success(retData);
    
    }
/**
   * D6查询区块链证书详情
   */
    @PostMapping("queryBlockchainCertificationDetail")
    public OkrResult<QueryBlockchainCertificationDetailRespDto> queryBlockchainCertificationDetail(@RequestBody @Validated QueryBlockchainCertificationDetailReqDto reqDTO){
    return OkrResult.success(blockchainService.queryBlockchainCertificationDetail(reqDTO));
    }
/**
   * D6存档区块链证书
   */
    @PostMapping("archiveBlockchainCertification")
    public OkrResult<ArchiveBlockchainCertificationRespDto> archiveBlockchainCertification(@RequestBody @Validated ArchiveBlockchainCertificationReqDto reqDTO){
    return OkrResult.success(blockchainService.archiveBlockchainCertification(reqDTO));
    }
/**
   * D6获取上链证书(公共)
   */
    @PostMapping("queryBlockchainCertificationDetailCom")
    public OkrResult<QueryBlockchainCertificationDetailComRespDto> queryBlockchainCertificationDetailCom(@RequestBody @Validated QueryBlockchainCertificationDetailComReqDto reqDTO){
    return OkrResult.success(blockchainService.queryBlockchainCertificationDetailCom(reqDTO));
    }
}
